﻿using System;

namespace Fast
{
    public interface IJsonSerializer
    {
        IJsonSerializerProvider SerializerProvider { get; }

        /// <summary>
        /// 序列化成 Json 字符串
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="camelCase">是否采用驼峰命名法</param>
        /// <param name="indented">是否缩进</param>
        /// <returns></returns>
        string Serialize(object obj, bool camelCase = true, bool indented = false);

        /// <summary>
        /// 反序列化成指定类型对象
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="jsonString">目标Json字符串</param>
        /// <param name="camelCase">是否采用驼峰命名法</param>
        /// <returns></returns>
        T Deserialize<T>(string jsonString, bool camelCase = true);

        /// <summary>
        /// 反序列化成 <see cref="object"/> 类型对象
        /// </summary>
        /// <param name="type"></param>
        /// <param name="jsonString">目标Json字符串</param>
        /// <param name="camelCase">是否采用驼峰命名法</param>
        /// <returns></returns>
        object Deserialize(Type type, string jsonString, bool camelCase = true);
    }
}
